package com.hwl.lab.controller;

import com.hwl.lab.entity.Area;
import com.hwl.lab.entity.Institution;
import com.hwl.lab.service.AreaService;
import com.hwl.lab.service.InstitutionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

@CrossOrigin //允许跨域请求
@RestController
public class InstitutionController {

    @Autowired
    private InstitutionService institutionService;
    //查询所有（分页）
    @GetMapping("/findInstitutionAll/{page}/{size}")
    public Page<Institution> findAreaAll(@PathVariable("page") Integer page, @PathVariable("size") Integer size){
        return institutionService.findAll(page,size);
    }
    //查询所有不分页
    @GetMapping("/findInstitutionAll")
    public List<Institution> findAll(){
        return institutionService.findAll();
    }

    //添加，修改
    @PostMapping("/saveInstitution")
    public void saveInstitution(@RequestBody(required=false) Institution institution){
        institutionService.saveInstitution(institution);
    }

    //删除
    @PostMapping("/deleteInstitution/{institutionid}")
    public void deleteInstitution(@PathVariable("institutionid") String institutionid){
        institutionService.deleteByInstitutionid(institutionid);
    }
}
